package com.koalac.ironman.net.pojo.response;

import java.util.ArrayList;

import org.json.JSONArray;
import org.json.JSONObject;

/**
 * 检查区名称
 * 
 * @author cyleung Sep 11, 2014
 */
public class District extends BaseResponse {
	/**
	 * 检查区id
	 */
	private int id = 0;
	/**
	 * 检查区名称
	 */
	private String name = "";
	/**
	 * 检查区地点列表
	 */
	private ArrayList<Position> positions = new ArrayList<Position>();
	/**
	 * 区域所在的组是否处于展开的状态(本地的变量,无需网络获取)
	 */
	private boolean isExpanded = false;

	public void init(JSONObject source) {
		if (null != source) {
			id = source.optInt("dist_id");
			name = source.optString("name");
			JSONArray jArray = source.optJSONArray("positions");
			for (int i = 0; i < jArray.length(); i++) {
				Position position = new Position();
				position.init(jArray.optJSONObject(i));
				positions.add(position);
			}
		}
	}

	/**
	 * 获取检查区id
	 */
	public int getId() {
		return id;
	}

	/**
	 * 获取检查区名称
	 */
	public String getName() {
		return name;
	}

	/**
	 * 获取检查区地点列表
	 */
	public ArrayList<Position> getPositions() {
		return positions;
	}

	public void setId(int id) {
		this.id = id;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void setPositions(ArrayList<Position> positions) {
		this.positions = positions;
	}

	public boolean isExpanded() {
		return isExpanded;
	}

	public void setExpanded(boolean isExpanded) {
		this.isExpanded = isExpanded;
	}

}
